import { http } from "@/utils/http"
import { CommonResponse } from "./common"


/**
 * 商品配置列表请求参数
 */
export type ProductConfigListRequest = {
  pageNum: number
  pageSize: number
}

/**
 * 商品配置查询产品列表
 */
export function getGoodsListApi() {
  return http.request<CommonResponse>('get', '/api/platform/goods/list')
}


/**
 * 查询关联产品列表
 */
export function getGoodsListByConfigIdApi() {
  return http.request<CommonResponse>('get', `/api/platform/products/list`)
}

/**
 * 创建商品
 */
export function createGoodsApi(data: any) {
  return http.request<CommonResponse>('post', '/api/platform/goods/create', { data })
}

/**
 * 修改商品
 */
export function updateGoodsApi(id: number, data: any) {
  return http.request<CommonResponse>('put', `/api/platform/goods/${id}`, { data })
}

/**
 * 上下架商品
 */
export function updateGoodsStatusApi(data: { id: number, state: number }) {
  return http.request<CommonResponse>('post', `/api/platform/goods/state`, { data })
}